<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width"/>
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>首页</title>
    <link rel="stylesheet" type="text/css" href="../../css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/main.css" />

    <link rel="stylesheet" type="text/css" href="../../css/colleague.css" />

    <script type="text/javascript" src="../../script/api.js"></script>
    <script type="text/javascript" src="../../script/jquery.js"></script>

    <script type="text/javascript" src="../../script/main.js"></script>
</head>
<body>
  <div id="header">
      <div id="back"></div>
      <h3>职业标准管理</h3>
      <a class="add_pro" onclick="openPage('add_professions','./add_professions.html')"></a>
  </div>
  <div id="all" style="height:500px;">
    <div class="pro">
    </div>
    <!-- <div class="list">
      <div class="name">职业名称：</div>
      <div class="code">职业序号：<span>1</span></div>
        <button class="btn btn-info">删除</button>
    </div> -->
    <!-- <div class="kind">
      <div class="kind_span"><span>意见所属类别</span></div>
      <div class="kind_selete">
        <div class="btn-toolbar" role="toolbar">
          <div class="btn-group">
              <button type="button" class="btn btn-default kind_selete_1">bug</button>
           </div>
          <div class="btn-group">
              <button type="button" class="btn btn-default kind_selete_2">产品建议</button>
          </div>
          <div class="btn-group">
              <button type="button" class="btn btn-default kind_selete_3">吐槽</button>
          </div>
          <div class="btn-group">
              <button type="button" class="btn btn-default kind_selete_4">其他</button>
          </div>
        </div>
      </div>
    </div> -->
    <!-- <div class="contact_way">
      <div class="contact_way_span"><span>你的联系方式</span></div>
      <textarea name="contact_way_span_text" class="contact_way_span_text" placeholder="留下邮箱或电话，方便我们联系你哦"></textarea>
    </div> -->
  </div>

</body>
<script>
  apiready=function(){
    //------------------------------------------------------------
    var aid=$api.getStorage('aid');
    var url='/api/professions/list';
    var functionRet=function(ret){
      console.log(JSON.stringify(ret));
      var btn="";
      $.each(ret, function(commentIndex, comment){
          var templates='<div class="list"><div class="content"><div class="name">职业名称：'+ret[commentIndex].name+'</div><div class="code">职业序号：<span>'+ret[commentIndex].code+'</span></div></div><button class="btn btn-info" pro_id="'+ret[commentIndex].id+'">删除</button></div>';
          $(".pro").append(templates);
     });
    }
    var functionErr=function(err){
        showProgress();
    }
    //加载项目列表
    get(url,functionRet,functionErr);
  }
  $(".myBtn").click(function(){
    openPage('add_professions','./add_professions.html');
  })
  $(".pro").on("click",".list .content",function(e){
    var list=$(this);
    var id=$(this).parent().find(".btn").attr("pro_id");
    console.log(id);
    //打开一个新的页面，并且传递参数
    api.openWin({
        name: 'pro_detail',
        url: './professions_detail.html',
        pageParam: {
            id: id
        }
    });
  });
  $(".pro").on("click",".list .btn",function(e){
    var button=$(this);
    api.confirm({
        title: '提示',
        msg: '确定要删除该标准吗',
        buttons: ['确定', '取消']
    }, function(ret, err) {
        var index = ret.buttonIndex;
        console.log(JSON.stringify(button));
        var id=button.attr("pro_id");
        console.log(id);
        var data="";
        var url='/api/professions/'+id;
        if(index==1){
          var functionRet=function(ret){
          }
          var functionErr=function(err){
            if(err.statusCode==200){
              button.parent().remove();
              toast("删除成功","bottom");
            }

          }
          //删除职业标准
          deleteData(url,data,functionRet,functionErr);
        }
    });
  })
  //刷新界面
  function reloadHtml(){
    window.location.reload();
  }
</script>
<script>

  $(function(){
    back();
  })
</script>
</html>
